home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performCreatePartition.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.7 KB  |  352 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  March 19, 1997
  22. //
  23. //  Description:
  24. //
  25. // An option window used to create a named partition.
  26. // A partition is a group of non-overlapping sets.
  27. //
  28.  
  29. //
  30. //  Procedure Name:
  31. //      setOptionVars
  32. //
  33. //  Description:
  34. //        Initialize the option values.
  35. //
  36. //  Input Arguments:
  37. //        Whether to set the options to default values.
  38. //
  39. //  Return Value:
  40. //      None.
  41. //
  42. proc setOptionVars(int $forceFactorySettings)
  43. {
  44.     // The variables in this "option" box are not options because
  45.     // bug reports (84564) indicated that users did not want the options
  46.     // to carry over from session to session.
  47.     //
  48. }
  49.  
  50. //
  51. //  Procedure Name:
  52. //      createPartitionSetup
  53. //
  54. //  Description:
  55. //        Update the state of the option box UI to reflect the option values.
  56. //
  57. //  Input Arguments:
  58. //      parent               - Top level parent layout of the option box UI.
  59. //                             Required so that UI object names can be 
  60. //                             successfully resolved.
  61. //
  62. //    forceFactorySettings - Whether the option values should be set to
  63. //                             default values.
  64. //
  65. //  Return Value:
  66. //      None.
  67. //
  68. global proc createPartitionSetup(string $parent, int $forceFactorySettings)
  69. {
  70.     // Retrieve the option settings
  71.     //
  72.     setOptionVars( $forceFactorySettings );
  73.     
  74.     textFieldGrp -e -text "partition1" partitionNameWidget;    
  75.  
  76.     setParent $parent;
  77. }
  78.  
  79. //
  80. //  Procedure Name:
  81. //      createPartitionCallback
  82. //
  83. //  Description:
  84. //        Update the option values with the current state of the option box UI.
  85. //
  86. //  Input Arguments:
  87. //      parent - Top level parent layout of the option box UI.  Required so
  88. //               that UI object names can be successfully resolved.
  89. //
  90. //    doIt   - Whether the command should execute.
  91. //
  92. //  Return Value:
  93. //      None.
  94. //
  95. global proc createPartitionCallback(string $parent, int $doIt)
  96. {
  97.     setParent $parent;
  98.  
  99.     if ($doIt) {
  100.         performCreatePartition 0; 
  101.         addToRecentCommandQueue "performCreatePartition 0" "CreatePartition";
  102.     }
  103. }
  104.  
  105. //
  106. //  Procedure Name:
  107. //      createPartitionOptions
  108. //
  109. //  Description:
  110. //        Construct the option box UI.  Involves accessing the standard option
  111. //        box and customizing the UI accordingly.
  112. //
  113. //  Input Arguments:
  114. //      None.
  115. //
  116. //  Return Value:
  117. //      None.
  118. //
  119. proc createPartitionOptions()
  120. {
  121.     //    Name of the command for this option box.
  122.     //
  123.     string $commandName = "createPartition";
  124.  
  125.     //    Build the option box actions.
  126.     //
  127.     string $callback = ($commandName + "Callback");
  128.     string $setup = ($commandName + "Setup");
  129.  
  130.     //    STEP 1:  Get the option box.
  131.     //    ============================
  132.     //
  133.     //    The value returned is the name of the layout to be used as
  134.     //    the parent for the option box UI.
  135.     //
  136.     string $layout = getOptionBox();
  137.     setParent $layout;
  138.     
  139.     //    STEP 2:  Pass the command name to the option box.
  140.     //    =================================================
  141.     //
  142.     //    Any default option box behaviour based on the command name is set 
  143.     //    up with this call.  For example, updating the 'Help' menu item with
  144.     //    the name of the command.
  145.     //
  146.     setOptionBoxCommandName("partition");
  147.     
  148.     //    STEP 3:  Activate the default UI template.
  149.     //    ==========================================
  150.     //
  151.     //    Activate the default UI template so that the layout of this 
  152.     //    option box is consistent with the layout of the rest of the 
  153.     //    application.
  154.     //
  155.     setUITemplate -pushTemplate DefaultTemplate;
  156.  
  157.     //    STEP 4: Create option box contents.
  158.     //    ===================================
  159.     //    
  160.     //    This, of course, will vary from option box to option box.    
  161.     
  162.     //    Turn on the wait cursor.
  163.     //
  164.     waitCursor -state 1;
  165.  
  166.     tabLayout -tabsVisible 0 -scrollable 1;
  167.     
  168.     string $parent = `columnLayout -adjustableColumn 1`;
  169.  
  170.     string $tabForm = `columnLayout -adjustableColumn true`;
  171.  
  172.     // partition name
  173.     //
  174.     formLayout fontLayout;
  175.         textFieldGrp
  176.             -label "Name"
  177.             partitionNameWidget;    
  178.  
  179.     //    Turn off the wait cursor.
  180.     //
  181.     waitCursor -state 0;
  182.     
  183.     //    Step 5: Deactivate the default UI template.
  184.     //    ===========================================
  185.     //
  186.     setUITemplate -popTemplate;
  187.  
  188.     //    Step 6: Customize the buttons.  
  189.     //    ==============================
  190.     //
  191.     //    Provide more descriptive labels for the buttons.  This is not 
  192.     //    necessary, but in some cases, for example, a button labelled 
  193.     //    'Create' may be more meaningful to the user than one labelled
  194.     //    'Apply'.
  195.     //
  196.     //    Disable those buttons that are not applicable to the option box.
  197.     //
  198.     //    Attach actions to those buttons that are applicable to the option
  199.     //    box.  Note that the 'Close' button has a default action attached 
  200.     //    to it that will hide the window.  If a a custom action is
  201.     //    attached to the 'Close' button then be sure to call the 'hide the
  202.     //    option box' procedure within the custom action so that the option
  203.     //    box is hidden properly.
  204.  
  205.     //    'Apply' button.
  206.     //
  207.     string $applyBtn = getOptionBoxApplyBtn();
  208.     button -edit
  209.         -command ($callback + " " + $parent + " " + 1)
  210.         $applyBtn;
  211.  
  212.     //    'Save' button.
  213.     //
  214.     string $saveBtn = getOptionBoxSaveBtn();
  215.     button -edit 
  216.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  217.         $saveBtn;
  218.  
  219.     //    'Reset' button.
  220.     //
  221.     string $resetBtn = getOptionBoxResetBtn();
  222.     button -edit 
  223.         -command ($setup + " " + $parent + " " + 1)
  224.         $resetBtn;
  225.  
  226.     //    Step 7: Set the option box title.
  227.     //    =================================
  228.     //
  229.     setOptionBoxTitle("Partition Options");
  230.  
  231.     //    Step 8: Customize the 'Help' menu item text.
  232.     //    ============================================
  233.     //
  234.     setOptionBoxHelpTag( "CreatePartition" );
  235.  
  236.     //    Step 9: Set the current values of the option box.
  237.     //    =================================================
  238.     //
  239.     eval (($setup + " " + $parent + " " + 0));    
  240.     
  241.     //    Step 10: Show the option box.
  242.     //    =============================
  243.     //
  244.     showOptionBox();
  245. }
  246.  
  247. //
  248. //  Procedure Name:
  249. //      createPartitionHelp
  250. //
  251. //  Description:
  252. //        Return a short description about this command.
  253. //
  254. //  Input Arguments:
  255. //      None.
  256. //
  257. //  Return Value:
  258. //      string.
  259. //
  260. proc string createPartitionHelp()
  261. {
  262.  
  263.     return 
  264.     "  Command: Create Partition - create a partition.\n" +
  265.     "Selection: Selected sets are added to the partition.";
  266. }
  267.  
  268. //
  269. //  Procedure Name:
  270. //      assembleCmd
  271. //
  272. //  Description:
  273. //        Construct the command that will apply the option box values.
  274. //
  275. //  Input Arguments:
  276. //      None.
  277. //
  278. proc string assembleCmd()
  279. {
  280.     string $cmd;
  281.  
  282.     setOptionVars(false);
  283.  
  284.     // get the partition name
  285.     string $partitionName = "partition1";
  286.     if (`textFieldGrp -exists partitionNameWidget`) {
  287.         $partitionName = `textFieldGrp -q -text partitionNameWidget`;
  288.     }
  289.  
  290.     // create the partition command string
  291.     if (size($partitionName)) {
  292.         $cmd = "partition -name "+$partitionName;
  293.     } else {
  294.         $cmd = "partition";
  295.     }
  296.  
  297.     return $cmd;
  298. }
  299.  
  300. //
  301. //  Procedure Name:
  302. //      performCreatePartition
  303. //
  304. //  Description:
  305. //        Perform the create partition command using the corresponding 
  306. //        option values.  This procedure will also show the option box
  307. //        window if necessary as well as construct the command string
  308. //        that will invoke the createPartition command with the current
  309. //        option box values.
  310. //
  311. //  Input Arguments:
  312. //      0 - Execute the command.
  313. //      1 - Show the option box dialog.
  314. //      2 - Return the command.
  315. //
  316. global proc string performCreatePartition(int $action)
  317. {
  318.     string $cmd = "";
  319.  
  320.     switch ($action) {
  321.  
  322.         //    Execute the command.
  323.         //
  324.         case 0:
  325.             //    Get the command.
  326.             //
  327.             $cmd = `assembleCmd`;
  328.  
  329.             //    Execute the command with the option settings.
  330.  
  331.             evalEcho($cmd);
  332.  
  333.             break;
  334.  
  335.         //    Show the option box.
  336.         //
  337.         case 1:
  338.             createPartitionOptions;
  339.             break;
  340.  
  341.         //    Return the command string.
  342.         //
  343.         case 2:
  344.             //    Get the command.
  345.             //
  346.             $cmd = `assembleCmd`;
  347.             break;
  348.     }
  349.     return $cmd;
  350. }
  351.  
  352.